from flask import Blueprint,request,jsonify
from service.task import task_service

app = Blueprint("httpd2",__name__)

@app.route('/task/findPage',methods=["get"])
def findPage():
    """ 查询资料
    ---
    tags: ["task"]
    parameters:
      - name: deviceName
        in: query
      - name: isHistory
        in: query
      - name: pageNum
        in: query
      - name: pageSize
        in: query
    responses:
      200:
        description: ""
    """
    deviceName = str(request.args.get('deviceName'))
    isHistory = int(request.args.get('isHistory'))
    pageSize = int(request.args.get('pageSize'))
    pageNum = int(request.args.get('pageNum'))

    if isHistory==1 :
      res = task_service.findPageHistory(deviceName,pageNum,pageSize)
    else:
      res = task_service.findPage(deviceName,pageNum,pageSize)
    return jsonify(res)


